package cn.yonyong.base.project.service.impl;

import cn.yonyong.base.project.mapper.TblDepartmentMapper;
import cn.yonyong.base.project.service.TreeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @created with IDEA
 * @author: yonyong
 * @version: 1.0.0
 * @date: 2019/9/29
 * @time: 22:36
 **/
@Service
public class TreeServiceImpl implements TreeService {
    @Resource
    private TblDepartmentMapper tblDepartmentMapper;
    @Override
    public List<Map<String, Object>> getAsyncAffixTreeData(String root_id, String departcode, String parentcode) {
        List<Map<String,Object>> list = new ArrayList<>();
        if (root_id == null || root_id.trim().isEmpty()) {
            return list;
        }
        //加载父节点和第一次子节点
        if(parentcode == null || parentcode.trim().isEmpty()){
            list = tblDepartmentMapper.getFirstLoadTreeData(root_id);
            return list;
        }
        list = tblDepartmentMapper.getMapDataByFkPid( departcode);
        return list;
    }
}
